basedir := ../..
antlr  := antlr
srcdir := .
pathhere := vm/test
objdir := $(basedir)/obj/$(pathhere)

repdir := rep
vmdir := vm

tests := BuiltinTest.hpp



CXX = ccache g++
COMPILEFLAGS = -Wall -I/usr/local/include -I$(basedir) -I/usr/local/include/gc -g
LINKFLAGS = -L/usr/local/lib -L$(basedir)/obj/$(repdir) -L$(basedir)/obj/$(vmdir) -lcppunit -ldl -lantlr -lgc

objnameshere := TestMain.o
objnamesvm := Ref.o opcodes.o builtins.o mainloop.o
objnamesrep := Slot.o Integer.o Type.o Continuation.o Cons.o Lambda.o

objfileshere := $(addprefix $(objdir)/, $(objnameshere))
objfilesvm := $(addprefix $(basedir)/obj/$(vmdir)/, $(objnamesvm))
objfilesrep := $(addprefix $(basedir)/obj/$(repdir)/, $(objnamesrep))

executables := vmtest

all: vmtest

test: TestMain.o
	$(CXX) $(LINKFLAGS) $(objfileshere) $(objfilesvm) $(objfilesrep) -o $(objdir)/test

%.o: %.cpp
	$(CXX) -c $< -o $(objdir)/$@ $(COMPILEFLAGS)

check: test
	echo "Running tests..."
	$(objdir)/test

clean: 
	-rm $(objdir)/*